﻿<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="CustomerCareAutoResult.aspx.cs" Inherits="famails.BackEnd.Customer.CustomerCareAutoResult" MasterPageFile="~/Master.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <style>
        #contentjqxgrid {
            width: 100% !important;
        }

        #pagerjqxgrid {
            width: 100% !important;
        }

        #contentjqxgrid_error {
            width: 100% !important;
        }

        #pagerjqxgrid_error {
            width: 100% !important;
        }
    </style>

    <div style="width: 100%; padding: 10px;">
        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;">
            <asp:Panel Visible="false" ID="pnError" runat="server">

                <div class="error-box round">
                    <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
                </div>
            </asp:Panel>
            <asp:Panel Visible="false" ID="pnSuccess" runat="server">
                <div class="confirmation-box round">
                    <asp:Label ID="lblSuccess" runat="server" Text=""></asp:Label>
                </div>
            </asp:Panel>
        </div>

        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" id="divList" style="border: 1px solid #333; padding: 0px; margin-bottom: 10px;">
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 20px; background: #000; color: #fff; font-size: 18px; font-weight: bold; position: relative;">
                Kết quả sự kiện
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 0px;">
                <div class="col-md-4 col-xs-6 col-sm-4 col-lg-4" style="height: auto; padding: 10px;">
                    <label for="simple-input" style="float: left; padding: 6px 20px 0px 0px; font-weight: bolder; text-transform: none">
                        Từ ngày</label>
                    <div id="txtFromDate"></div>
                </div>
                <div class="col-md-4 col-xs-6 col-sm-4 col-lg-4" style="height: auto; padding: 10px;">
                    <label for="simple-input" style="float: left; padding: 6px 20px 0px 0px; font-weight: bolder; text-transform: none">
                        Đến ngày</label>
                    <div id="txtToDate"></div>
                </div>
                <div class="col-md-4 col-xs-6 col-sm-4 col-lg-4" style="height: auto; padding: 10px;">
                    <fieldset>
                        <div id="btnSearch" style="float: left; margin-right: 10px; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px;" class="btn">
                            <span style="margin-right: 10px;" class="fa fa-desktop"></span>Lọc dữ liệu
                        </div>
                    </fieldset>
                </div>
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 0px; background: #333;">
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                    <label for="simple-input" style="float: left; padding: 10px 20px 0px 0px; font-weight: bolder; font-size: 20px; color: #fff; text-transform: none">
                        Email sống</label>
                </div>
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto; padding: 15px 0px 0px 0px;">

                    <div id="btnExportExcel" style="float: right; margin-right: 10px; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px; border: 1px solid #fff;" class="btn">
                        <span style="margin-right: 10px;" class="fa fa-mail-forward"></span>Xuất dữ liệu
                    </div>

                </div>
            </div>
            <div id='jqxWidget' style="width: 100% !important; font-size: 13px; font-family: Verdana; float: left;">
                <div id="jqxgrid" style="width: 100% !important;">
                </div>
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 0px; background: #333;">
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                    <label for="simple-input" style="float: left; padding: 10px 20px 0px 0px; font-weight: bolder; font-size: 20px; color: #fff; text-transform: none">
                        Email chết</label>
                </div>
                <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6" style="height: auto; padding: 10px 0px 0px 0px;">
                    <div id="btnExportExcel_error" style="float: right; margin-right: 10px; margin-top: 5px; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px; border: 1px solid #fff;" class="btn">
                        <span style="margin-right: 10px;" class="fa fa-mail-forward"></span>Xuất dữ liệu
                    </div>

                </div>
            </div>
            <div id='jqxWidget_error' style="width: 100% !important; font-size: 13px; font-family: Verdana; float: left;">
                <div id="jqxgrid_error" style="width: 100% !important;">
                </div>
            </div>

        </div>
        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="border: 1px solid #333; padding: 0px; margin-bottom: 10px;">
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 20px; background: #000; color: #fff; font-size: 18px; font-weight: bold;">
                Thống kê các chiến dịch
            </div>

            <asp:Repeater ID="dlContentSendEvent" runat="server">
                <ItemTemplate>
                    <asp:Panel ID="pnReport" runat="server">
                        <div class="col-md-12 col-sm-12 col-lg-12 col-xs-12" style="padding: 0px;">
                            <div class="panel panel-default" style="margin: 0px; border: 0px; padding: 0px;">
                                <div class="panel-heading" style="background:none; border-bottom: 1px solid #ddd; border-radius: 0px; color: #333;">
                                    <h4 class="panel-title">
                                        <a data-toggle="collapse" style="font-weight: normal;font-size:14px;display:inline-block;white-space: nowrap;overflow:hidden !important;text-overflow: ellipsis;" href='#<%#Eval("id") %>'>
                                            <%#Eval("Subject") %>
                                        </a>
                                    </h4>
                                </div>
                                <div id="<%#Eval("id") %>" class='<%# (Convert.ToDecimal(Eval("TotalSend"))>0?"panel-collapse collapse in":"panel-collapse collapse")%>'>
                                    <div class="panel-body" style="padding: 5px 0px;">
                                        <div style="padding: 0px 0px;">
                                            <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: auto; padding: 0px; margin-top: 10px; margin-bottom: 10px; border: 1px solid #dedede; border-right: 0px;">
                                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 10px 5px; text-align: center; background: #f9f9f9;display:inline-block;white-space: nowrap;overflow:hidden !important;text-overflow: ellipsis;">
                                                    <asp:Label ID="lblCampianName" Style="font-size: 16px; line-height: 20px; color: #333; font-weight: bold;" runat="server" Text='<%#Eval("Subject") %>'></asp:Label>
                                                </div>
                                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px;">
                                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                                        Email gửi : 
                                                    </div>
                                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                                        <asp:Label ID="lblEmailSend" runat="server" Text='<%#Eval("Email") %>'>&nbsp;</asp:Label>
                                                    </div>
                                                </div>
                                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px; background: #f9f9f9;">
                                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                                        Nhóm email nhận : 
                                                    </div>
                                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                                        <asp:Label ID="lblGroupEmailTo" runat="server" Text='<%#Eval("Name") %>'>&nbsp;</asp:Label>
                                                    </div>
                                                </div>
                                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px;">
                                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                                        Bắt đầu : 
                                                    </div>
                                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                                        <asp:Label ID="lblDateStart" runat="server" Text='<%#(Eval("StartSend")+""==""?"":Convert.ToDateTime(Eval("StartSend")).ToString("dd/MM/yyyy HH:mm:ss")) %>'>&nbsp;</asp:Label>
                                                    </div>
                                                </div>
                                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px; background: #f9f9f9;">
                                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                                        Số email gửi : 
                                                    </div>
                                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                                        <asp:Label ID="lblTotalMailSend" runat="server" Text='<%#Eval("TotalSend") %>'>&nbsp;</asp:Label>
                                                    </div>
                                                </div>
                                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px;">
                                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                                        Số email đã mở : 
                                                    </div>
                                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                                        <asp:Label ID="lblOpened" runat="server" Text='<%#Eval("TotalOpen") %>'>&nbsp;</asp:Label>
                                                    </div>
                                                </div>
                                                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px; background: #f9f9f9;">
                                                    <div class="col-md-4 col-xs-4 col-sm-4 col-lg-4" style="height: auto; padding: 10px 5px;">
                                                        Số email chưa mở : 
                                                    </div>
                                                    <div class="col-md-8 col-xs-8 col-sm-8 col-lg-8" style="height: auto; min-height: 35px; padding: 10px 5px;">
                                                        <asp:Label ID="lblNotOpen2" runat="server" Text='<%#Eval("TotalNotOpen") %>'>&nbsp;</asp:Label>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: auto; padding: 10px 0px;">
                                                <asp:Label ID="lblChart" runat="server" Text="Không có dữ liệu"></asp:Label>
                                                <%--<div id="chart_div" style="width: 100%; height: 270px;"></div>--%>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </asp:Panel>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </div>
    <script type="text/javascript">
        function getQueryStrings() {
            var assoc = {};
            var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
            var queryString = location.search.substring(1);
            var keyValues = queryString.split('&');

            for (var i in keyValues) {
                var key = keyValues[i].split('=');
                if (key.length > 1) {
                    assoc[decode(key[0])] = decode(key[1]);
                }
            }

            return assoc;
        }
        jQuery(function ($) {
            // 
            $("#txtFromDate").jqxDateTimeInput({ width: '120px', height: '25px' });
            $("#txtToDate").jqxDateTimeInput({ width: '120px', height: '25px' });

            $("#btnExportExcel").click(function () {
                $("#jqxgrid").jqxGrid('exportdata', 'xls', 'registeremaillist');
            });
            var qs = getQueryStrings();
            var eventid = qs["Id"];
            //alert(id);
            $("#btnSearch").click(function () {
                $("#jqxgrid").jqxGrid('showloadelement');
                var postValue = "{eventID:" + eventid + ",from:'" + $('#txtFromDate').val() + "',to:'" + $('#txtToDate').val() + "'}";
                $.ajax({
                    type: "POST",
                    url: "event-report.aspx/search",
                    data: postValue,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        var source =
                {
                    datatype: "json",
                    datafields: [
                        { name: 'EventId', type: 'int' },
                        { name: 'GroupId', type: 'int' },
                          { name: 'FullName', type: 'string' },
                          { name: 'EmailID', type: 'string' },
                          { name: 'Job', type: 'string' },
                          { name: 'Company', type: 'string' },
                          { name: 'Sex', type: 'string' },
                          { name: 'Phone', type: 'string' },
                          { name: 'Address', type: 'string' },
                        { name: 'Birthday', type: 'date' },
                        { name: 'CreateDate', type: 'date' }
                    ],
                    id: 'ID',
                    localdata: data,
                    pager: function (pagenum, pagesize, oldpagenum) {
                    }
                };
                        var dataAdapter = new $.jqx.dataAdapter(source);
                        $("#jqxgrid").jqxGrid(
                        {
                            width: $('#jqxWidget').width(),
                            source: dataAdapter,
                            selectionmode: 'multiplerowsextended',
                            sortable: true,
                            pageable: true,
                            autoheight: true,
                            columnsresize: true,
                            columns: [
                              { text: 'Họ tên', width: 200, datafield: 'FullName' },
                              { text: 'Email', width: 200, datafield: 'EmailID' },
                              { text: 'Giới tính', datafield: 'Sex' },
                              { text: 'Ngày sinh', datafield: 'Birthday' },
                              { text: 'Nghề nghiệp', datafield: 'Job' },
                              { text: 'Công ty', datafield: 'Company' },
                              { text: 'Điện thoại', datafield: 'Phone' },
                              { text: 'Địa chỉ', datafield: 'Address' },
                              { text: 'Thời gian đăng ký', datafield: 'CreateDate', cellsalign: 'center', cellsformat: 'dd/MM/yyyy HH:mm:ss' }
                            ]
                        });

                    }
                });
            });
           // $('#btnSearch').trigger('click');
            $("#jqxgrid_error").jqxGrid('showloadelement');
            var postValue = "{id:" + eventid + "}";
            $.ajax({
                type: "POST",
                url: "event-report.aspx/ErrorMailList",
                data: postValue,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var source =
            {
                datatype: "json",
                datafields: [
                    { name: 'ID', type: 'decimal' },
                      { name: 'Message', type: 'string' },
                      { name: 'To', type: 'string' },
                      { name: 'Status', type: 'string' },
                    { name: 'SendTime', type: 'date' }
                ],
                id: 'ID',
                localdata: data,
                pager: function (pagenum, pagesize, oldpagenum) {
                }
            };
                    var dataAdapter = new $.jqx.dataAdapter(source);
                    $("#jqxgrid_error").jqxGrid(
                    {
                        width: $('#jqxWidget').width(),
                        source: dataAdapter,
                        selectionmode: 'multiplerowsextended',
                        sortable: true,
                        pageable: true,
                        autoheight: true,
                        columnsresize: true,
                        columns: [
                          { text: 'Email', width: 200, datafield: 'To' },
                          { text: 'Thời gian gửi', datafield: 'SendTime', cellsalign: 'center', cellsformat: 'dd/MM/yyyy HH:mm:ss' },
                          { text: 'Tình trạng', datafield: 'Status', cellsformat: 'F2' },
                          { text: 'Mô tả', datafield: 'Message' }
                        ]
                    });

                }
            });
            $('#dataTables-example').dataTable();
        });

    </script>
    <%-- <script type="text/javascript">
        $(function () {
            $('#ContentPlaceHolder1_txtFromDate').datetimepicker({
                changeMonth: true, changeYear: true, timeFormat: "", dateFormat: "dd/mm/yy"
            });
            $('#ContentPlaceHolder1_txtToDate').datetimepicker({
                changeMonth: true, changeYear: true, timeFormat: "", dateFormat: "dd/mm/yy"
            });
        });
    </script>--%>
</asp:Content>


